﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using G.Navigate;

namespace G.WeiBo.View
{
    public partial class SettingPage : GBasePage
    {
        public SettingPage()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (settingPanel.DataContext == null)
            {
                switch (ThemeHelp.GetThemeType())
                {
                    case ThemeType.Black:
                        rdoBlack.IsChecked = true;
                        break;
                    case ThemeType.White:
                        rdoWhite.IsChecked = true;
                        break;
                }
                this.settingPanel.DataContext = APPConfig.Instance;
            }

        }


        private void btnSave_Click(object sender, EventArgs e)
        {
            if (rdoWhite.IsChecked == true)
            {
                ThemeHelp.SaveThemeType(ThemeType.White);
            }
            else if (rdoBlack.IsChecked == true)
            {
                ThemeHelp.SaveThemeType(ThemeType.Black);
            }
            if (MessageBox.Show("部分更改需要在重新启动程序以后才能使用，是否退出程序重新启动？", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                throw new ExitExeption("保存更改");
            }
        }

        private void btnEmail_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Phone.Tasks.EmailComposeTask task = new Microsoft.Phone.Tasks.EmailComposeTask();
            task.Subject = "问题反馈";
            task.To = "dagehaoshuang@163.com";
            task.Show();
        }
    }
}